package com.jiazhong.IO流.字节流;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Scanner;

public class OutputStreamDemo1 {
    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(System.in);
        FileOutputStream fileOutputStream = new FileOutputStream("d:/abc.txt");
        while (true){
            System.out.print("请输入内容:");
            //输入一行数据
            String str = scanner.nextLine();
            if(str.equals("exit")){
                break;//退出
            }
            //写入到目标文件中
            fileOutputStream.write(str.getBytes());
            fileOutputStream.write("\n".getBytes());
            fileOutputStream.flush();//刷新流
        }
        fileOutputStream.close();//关闭输出流
    }
}
